//获取应用实例
const app = getApp()
import api from '../../utils/api'

Page({
  data: {
    flag: 5,
    food:{},
    content: ''
  },
  onShow:function(){
    this.setData({
      food: app.globalData.evaluate
    })
  },
  bindTextAreaBlur: function (e) {
    this.setData({
      content: e.detail.value
    })
  },
  submit:function(){
    let content = this.data.content;
    let score = this.data.flag;
    let user = wx.getStorageSync("user");
    let food = this.data.food;
    let param = { "patientId": user.bh, "content": content, "score": score, "orderNo": food.FGuid }
    api.POST({
      // url: 'marking.action',
      url: 'marking_old.action',
      params: param,
      success: function (res) {
        let success = res.data.success;
        if (success == "true") {
          wx.showToast({
            icon: 'none',
            title: '评价成功',
          })
          app.globalData.sfpj = 1;
          setTimeout(function(){
            wx.navigateBack({
              delta: 1
            })
          },1000)
          
        } else {
          wx.showToast({
            icon: 'none',
            title: res.data.msg,
          })
        }
      },
      fail: function () {
        wx.showToast({
          icon: 'none',
          title: '请求失败',
        })
      },
    })
  },
  changeColor1: function () {
    var that = this;
    that.setData({
      flag: 1
    });
  },
  changeColor2: function () {
    var that = this;
    that.setData({
      flag: 2
    });
  },
  changeColor3: function () {
    var that = this;
    that.setData({
      flag: 3
    });
  },
  changeColor4: function () {
    var that = this;
    that.setData({
      flag: 4
    });
  },
  changeColor5: function () {
    var that = this;
    that.setData({
      flag: 5
    });
  },
})